﻿
CREATE PROCEDURE [dbo].[OPM_ReturnOrderMemo_GetList]
(
	@ShowHidden  bit = 0,
	@ShowDeleted bit = 0,
	@ReturnOrderId int
)

AS

	SELECT 		
		ROH.[Id],
		ROH.[ReturnOrderId],
		ROH.[Memo],
		ROH.[Published],
		ROH.[Deleted],
		ROH.[CreatedBy],
		ROH.[UpdatedBy],
		ROH.[CreatedOn],
		ROH.[UpdatedOn]
	    FROM dbo.[OPM_ReturnOrderMemo] ROH
        
        WHERE 
	    (ROH.Published = 1 OR @ShowHidden = 1) 
	    -- IF Show Hidden is true, then all records would be shown
	    -- IF Show Published, then display all records filter by t.Published = 1
	    AND    
	    (ROH.Deleted = 0 OR @ShowDeleted = 1)     
	    -- IF Show Deleted is true,  then all records would be shown
	    -- IF Show Deleted is false, then display all records filter by t.Deleted = 0
        
        AND ROH.ReturnOrderId = @ReturnOrderId
		ORDER BY ROH.Id DESC